$(function() {
	$('#naturaFeature_form')
			.validate(
					{
						errorElement : 'div',
						errorClass : 'help-block',
						focusInvalid : true,
						ignore : "",
						rules : {
//							overview : {
//								required : true,
//								maxlength : 500
//							}
						},

						messages : {
//							code : {
//								required : "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='color: red;'>请输入一些描述！</span>",
//								maxlength : "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style='color: red;'>最大长度不能超过500个字符！</span>"
//							}
						},

						highlight : function(e) {
							$(e).closest('.form-group').removeClass('has-info')
									.addClass('has-error');
						},

						success : function(e) {
							$(e).closest('.form-group')
									.removeClass('has-error').addClass(
											'has-info');
							// $(e).remove();
						}
					});

	$("#naturaFeature_add_climate").click(function() {
		naturaFeature_add_climate();
	});
	$("#naturaFeature_btn").click(function() {
		naturaFeature_add();
	});
	
	
		
		var check1 = $("input[name='wetlandLandformTypes']");
		$(check1[0]).attr("checked",true);
		var check2 = $("input[name='wetlandSoilTypes']");
		$(check2[0]).attr("checked",true);
		var check3 = $("input[name='wetlandPeatTypes']");
		$(check3[0]).attr("checked",true);
		var check4 = $("input[name='wetlandRevierBasins']");
		$(check4[0]).attr("checked",true);
		var check5 = $("input[name='wetlandWaterSituations']");
		$(check5[0]).attr("checked",true);
		var check6 = $("input[name='wetlandWaterRecharges']");
		$(check6[0]).attr("checked",true);
		var check7 = $("input[name='wetlandWaterDirections']");
		$(check7[0]).attr("checked",true);
		var check8 = $("input[name='wetlandWaterStabilitys']");
		$(check8[0]).attr("checked",true);
		var check9 = $("input[name='wetlandSediments']");
		$(check9[0]).attr("checked",true);
		
	
	
	
	
	
});

// 添加信息
function naturaFeature_add() {
	var option = {
		dataType : 'json',
		data : {wetlandParkId : wetlandParkId},
		success : function(value) {
			if (value == true) {
				naturaFeature.html(naturaFeature.text() + successHTML);
				$.gritter.add({
					title : '确认消息',
					text : '恭喜您,信息添加成功！',
					class_name : 'gritter-success'
				});
			} else {
				naturaFeature.html(naturaFeature.text() + warnHTML);
				$.gritter.add({
					title : '确认消息',
					text : '对不起,信息添加失败！',
					class_name : 'gritter-error'
				});
			}
		},
		error : function() {
			naturaFeature.html(naturaFeature.text() + warnHTML);
			$.gritter.add({
				title : '服务器错误',
				text : '对不起，服务器错误，请联系系统管理员！',
				class_name : 'gritter-error'
			});
		}
	};
	$("#naturaFeature_form").ajaxForm(option).submit();

}

function naturaFeature_add_climate(){
	var label = $('<label class="col-sm-3 control-label no-padding-right"></label>');
	var div = $('<div class="col-sm-9" style="margin-top: 1px;"> '+
					'<input type="text" name="wlin_climatic_region" class="col-xs-10 col-sm-5" placeholder=""> '+
					'<button style="margin-left: 2px;" class="btn btn-primary btn-sm" '+
						'type="button" onclick="naturaFeature_del_climate($(this))"> '+
						'<span aria-hidden="true" class="glyphicon glyphicon-minus"></span>删除 '+
					'</button> '+
				'</div>');
	$("#naturaFeature_climate_region").append(label).append(div);
}

function naturaFeature_del_climate(delBtn){
	delBtn.parent().prev().remove();
	delBtn.parent().remove();
}
